package com.xnfh.equipment.ui.activity

import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import com.flyco.tablayout.SlidingTabLayout
import com.xnfh.common.adapter.MyPageAdapter
import com.xnfh.common.utils.ViewFindUtils
import com.xnfh.equipment.R
import com.xnfh.equipment.databinding.ActivityKcEquipmentLogLayoutBinding
import com.xnfh.equipment.ui.fragment.EquipmentIrrigateFragment
import com.xnfh.equipment.ui.fragment.EquipmentSystemLogFragment
import com.xnfh.framework.base.BaseActivity

/**
 * @Description:设备详情日志
 * @Author: ziheng
 * @CreateDate: 2023/12/26 18:24
 * @UpdateUser: ziheng
 * @UpdateDate: 2023/12/26 18:24
 * @UpdateRemark: 更新说明
 */
class KcEquipmentLogActivity: BaseActivity<ActivityKcEquipmentLogLayoutBinding>(){
    override fun getLayoutID(): Int = R.layout.activity_kc_equipment_log_layout
    companion object {
        fun start(context: Context, bundle: Bundle? = null) {
            val intent = Intent(context, KcEquipmentLogActivity::class.java)
            if (bundle != null) {
                intent.putExtra("bundle", bundle)
            }
            context.startActivity(intent)
        }
    }

    private val mTitles = ArrayList<String>()
    private val mFragment = ArrayList<Fragment>()

    override fun init(savedInstanceState: Bundle?) {
        setHeaderTitle(getString(R.string.str_log))
        val bundleExtra = intent.getBundleExtra("bundle")

        val tabLayout = ViewFindUtils.find<SlidingTabLayout>(
            window.decorView,
            R.id.equipment_log_tablayout
        )
        mTitles.add(getString(R.string.system_log))//种植方案
        mTitles.add(getString(R.string.irrigate_log))//巡田记录
        mFragment.add(EquipmentSystemLogFragment.getInstance(bundleExtra))
        mFragment.add(EquipmentIrrigateFragment.getInstance(bundleExtra))
        val myPageAdapter = MyPageAdapter(supportFragmentManager, mFragment, mTitles)
        mBind.equipmentLogViewpage.adapter = myPageAdapter
        tabLayout.setViewPager(mBind.equipmentLogViewpage)
    }

    override fun observe() {

    }
}